<template>
  <div class="xtx-checkbox" @click="changeChecked()">
    <i v-if="checked" class="iconfont icon-checked"></i>
    <i v-else class="iconfont icon-unchecked"></i>
    <span v-if="$slots.default">
      <slot />
    </span>
  </div>
</template>

<script>
export default {
  props: ['val', 'title'],
  data() {
    return {
      checked: false
    }
  },
  methods: {
    changeChecked() {
     this.checked = !this.checked
     this.$emit('update:val',this.checked)
    }
  },
}
</script>

<style scoped lang="scss">
@import "@/assets/css/color.scss";
.xtx-checkbox {
  display: inline-block;
  margin-right: 2px;
  .icon-checked {
    color: $xtxColor;
    ~ span {
      color: $xtxColor;
    }
  }
  i {
    position: relative;
    top: 1px;
  }
  span {
    margin-left: 2px;
  }
}
</style>